<script>
	$(function() {
		$( "#txtNgaysinh" ).datepicker();
	});
</script>
<?php
if (!defined('WEB_ROOT')) {
	exit;
}

// make sure matg exists
if (isset($_GET['matg']) && $_GET['matg'] !='') {
	$matg = $_GET['matg'];
} else {
	// redirect to index.php 
	header('Location: index.php');
}
if (isset($_GET['nhomnc_id']) && $_GET['nhomnc_id'] > 0) {
	$nhomnc_id = (int)$_GET['nhomnc_id'];
} 

// Lấy thông tin tác giả
$sql = "SELECT tg.matg, tg.hotentg, tg.ngaysinh, tg.quequantg, tg.madv, tg.chucvu, tg.hocham, tg.hocvi
        FROM tacgia tg
		WHERE tg.matg = '$matg'";
		
	$result = mysql_query($sql) or die('Cannot get author. ' . mysql_error());
	$row    = mysql_fetch_assoc($result);
	extract($row);
	
	$sql = "SELECT id, tennnc
				FROM nhomnc
				ORDER BY id";
		$result = dbQuery($sql) or die('Cannot get Author Group. ' . mysql_error());
		
		$groups = array();
		$list = '';
		while($row = dbFetchArray($result)) {
			list($id, $name) = $row;
			$list .= "<option value=\"$id\"";
				if ($id == $nhomnc_id) {
					$list.= " selected";
				}
				$list .= ">$name</option>\r\n";
		}	

?> 

<form action="processAuthor.php?action=modifyAuthor&matg=<?php echo $matg; ?>&nhomnc_id=<?php echo nhomnc_id; ?>" method="post" enctype="multipart/form-data" name="frmAddAuthor" id="frmAddAuthor">
 <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable">
  <tr><td colspan="2" id="entryTableHeader">Sửa thông tin tác giả</td></tr>
  <tr> 
   <td width="150" class="label">Nhóm nghiên cứu</td>
   <td class="content"> <select name="cboGroup" id="cboGroup" class="box">
     <option value="" selected>-- Chọn nhóm nghiên cứu --</option>
<?php
	echo $list;
?>	 
    </select></td>
  </tr>
  <tr> 
	   <td width="150" class="label">Mã tác giả</td>
	   <td class="content"> <input name="txtMatg" type="text" class="box" id="txtMatg" readonly="true" style="background-color:#DADADA" value="<?php echo $matg; ?>"  size="20" maxlength="20"></td>
  </tr>
  <tr> 
	   <td width="150" class="label">Họ tên tác giả</td>
	   <td class="content"> <input name="txtHotentg" type="text" class="box" id="txtHotentg" value="<?php echo $hotentg; ?>"  size="40" maxlength="40"></td>
  </tr>
  <tr> 
	   <td width="150" class="label">Ngày sinh</td>
	   <td class="content"><input name="txtNgaysinh" type="text" id="txtNgaysinh" value="<?php echo $ngaysinh; ?>" size="20" maxlength="20" class="box"> </td>
  </tr>
  <tr> 
	   <td width="150" class="label">Quê quán</td>
	   <td class="content"><input name="txtQuequan" type="text" id="txtQuequan" value="<?php echo $quequantg; ?>" size="40" maxlength="40" class="box"> </td>
  </tr>
  <tr> 
	   <td width="150" class="label">Mã đơn vị</td>
	   <td class="content"><input name="txtMadv" type="text" id="txtMadv" value="<?php echo $madv; ?>" size="20" maxlength="20" class="box"> </td>
  </tr>
    <tr> 
	   <td width="150" class="label">Chức vụ</td>
	   <td class="content"><input name="txtChucvu" type="text" id="txtChucvu" value="<?php echo $chucvu; ?>" size="20" maxlength="20" class="box"> </td>
  </tr>
  <tr> 
	   <td width="150" class="label">Học hàm</td>
	   <td class="content"><input name="txtHocham" type="text" id="txtHocham" value="<?php echo $hocham; ?>" size="20" maxlength="20" class="box"> </td>
  </tr>
  <tr> 
	   <td width="150" class="label">Học vị</td>
	   <td class="content"><input name="txtHocvi" type="text" id="txtHocvi" value="<?php echo $hocvi; ?>" size="20" maxlength="20" class="box"> </td>
  </tr>
  <tr> 
	   <td width="150" class="label">Hình ảnh</td>
	   <td class="content"> <input name="fleImage" type="file" id="fleImage" class="box"> </td>
  </tr>
 </table>
 <p align="center"> 
  <input name="btnModifyAuthor" type="button" id="btnModifyProduct" value="Lưu thay đổi" onClick="checkAddAuthorForm();" class="box">
  &nbsp;&nbsp;<input name="btnCancel" type="button" id="btnCancel" value="Cancel" onClick="window.location.href='index.php';" class="box">  
 </p>
</form>
